﻿Imports System.Data.OleDb

Public Class ImportItemDetailsDAO
    Public Function ImportItemDetails_UpdateCheck(ByVal ImportItemID As Integer, _
                                                  ByVal ItemID As Integer) As Integer
        Dim para(2) As OleDbParameter
        para(0) = New OleDbParameter("@ImportItemID", ImportItemID)
        para(0).OleDbType = OleDbType.Integer

        para(1) = New OleDbParameter("@ItemID", ItemID)
        para(1).OleDbType = OleDbType.Integer

        para(2) = New OleDbParameter("@Quantity", OleDbType.Integer)
        para(2).Direction = ParameterDirection.Output

        objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_ImportItemDetails_UpdateCheck", para)
        Return para(2).Value
    End Function


    Public Function ImportItemDetails_Delete(ByVal ImportItemDetailID As Integer) As Boolean
        Dim para(0) As OleDbParameter
        para(0) = New OleDbParameter("@ImportItemDetailID", ImportItemDetailID)
        para(0).OleDbType = OleDbType.Integer

        Return objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_ImportItemDetails_Delete", para)
    End Function

    Public Function ImportItemDetails_Insert(ByVal ImportItemID As Integer, _
                                             ByVal ItemID As Integer, _
                                             ByVal Quantity As Integer, _
                                             ByVal BuyPrice As Decimal, _
                                             ByVal SellPrice As Decimal, _
                                             ByVal CreateBy As String, _
                                             ByVal ImportDate As Date, _
                                             ByVal Tax As Boolean) As Boolean

        Dim para(8) As OleDbParameter
        para(0) = New OleDbParameter("@ImportItemID", ImportItemID)
        para(0).OleDbType = OleDbType.Integer

        para(1) = New OleDbParameter("@ItemID", ItemID)
        para(1).OleDbType = OleDbType.Integer

        para(2) = New OleDbParameter("@Quantity", Quantity)
        para(2).OleDbType = OleDbType.Integer

        para(3) = New OleDbParameter("@BuyPrice", BuyPrice)
        para(3).OleDbType = OleDbType.Currency

        para(4) = New OleDbParameter("@SellPrice", SellPrice)
        para(4).OleDbType = OleDbType.Currency

        para(5) = New OleDbParameter("@CreateBy", CreateBy)
        para(5).OleDbType = OleDbType.VarWChar

        para(6) = New OleDbParameter("@ImportDate", ImportDate)
        para(6).OleDbType = OleDbType.Date

        para(7) = New OleDbParameter("@Tax", Tax)
        para(7).OleDbType = OleDbType.Boolean

        para(8) = New OleDbParameter("@ImportItemDetailID", OleDbType.Integer)
        para(8).Direction = ParameterDirection.Output

        objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_ImportItemDetails_Insert", para)
        Return para(8).Value
    End Function

    Public Function ImportItemDetails_Update(ByVal ImportItemDetailID As Integer, _
                                            ByVal ImportItemID As Integer, _
                                             ByVal ItemID As Integer, _
                                             ByVal Quantity As Integer, _
                                             ByVal BuyPrice As Decimal, _
                                             ByVal SellPrice As Decimal, _
                                             ByVal ImportDate As Date, _
                                             ByVal ModifiedBy As String) As Boolean
        Dim para(7) As OleDbParameter
        para(0) = New OleDbParameter("@ImportItemDetailID", ImportItemDetailID)
        para(0).OleDbType = OleDbType.Integer

        para(1) = New OleDbParameter("@ImportItemID", ImportItemID)
        para(1).OleDbType = OleDbType.Integer

        para(2) = New OleDbParameter("@ItemID", ItemID)
        para(2).OleDbType = OleDbType.Integer

        para(3) = New OleDbParameter("@Quantity", Quantity)
        para(3).OleDbType = OleDbType.Integer

        para(4) = New OleDbParameter("@BuyPrice", BuyPrice)
        para(4).OleDbType = OleDbType.Currency

        para(5) = New OleDbParameter("@SellPrice", SellPrice)
        para(5).OleDbType = OleDbType.Currency

        para(6) = New OleDbParameter("@ImportDate", ImportDate)
        para(6).OleDbType = OleDbType.VarWChar

        para(7) = New OleDbParameter("@ModifiedBy", ModifiedBy)
        para(7).OleDbType = OleDbType.VarWChar

        Return objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_ImportItemDetails_Update", para)

    End Function

    Public Function ImportItemDetails_PermitCheck(ByVal ImportItemID As Integer, _
                                                  ByVal ItemID As Integer) As Boolean
        Dim para(2) As OleDbParameter
        para(0) = New OleDbParameter("@ImportItemID", ImportItemID)
        para(0).OleDbType = OleDbType.Integer

        para(1) = New OleDbParameter("@ItemID", ItemID)
        para(1).OleDbType = OleDbType.Integer

        para(2) = New OleDbParameter("@Success", OleDbType.Boolean)
        para(2).Direction = ParameterDirection.Output

        objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_ImportItemDetails_PermitCheck", para)
        Return para(2).Value
    End Function



End Class
